package xio.ccf_201312;

import java.util.Scanner;

/**
 * 201312-3 最大的矩形 100分
 * Created by ywb47 on 2017/11/8.
 */
public class BigestRect {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] rect = new int[n];
        for (int i = 0; i < n; i++) {
            rect[i] = sc.nextInt();
        }

        int result = 0;


        for (int i = 0; i < n; i++) {
            // 以当前矩形高度为准，左右延伸 找到一个最大面积
            int width = 1;
            for (int j = i-1; j >= 0; j--) { //左
                if (rect[j] >= rect[i]){
                    width++;
                }else break;
            }
            for (int j = i+1; j < n; j++) { //右
                if (rect[j] >= rect[i]){
                    width++;
                }else break;
            }
            result = Math.max(result,width*rect[i]);
        }

        System.out.println(result);
    }
}
